{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import warnings\n",
    "from matplotlib import pyplot as plt\n",
    "import pandas as pd\n",
    "import pymssql\n",
    "import datetime\n",
    "\n",
    "from sqlalchemy import create_engine\n",
    "from sqlalchemy.types import VARCHAR, Float, Integer, Date, Numeric\n",
    "\n",
    "warnings.filterwarnings('ignore')\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "连接成功!\n"
     ]
    }
   ],
   "source": [
    "\n",
    "connect = pymssql.connect('192.168.3.112', 'sa', 'taotao778899!', 'DB_INFO', charset='utf8')  #建立连接\n",
    "if connect:\n",
    "    print(\"连接成功!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [],
   "source": [
    "a_path = 'F:\\HQData\\market_A\\\\'\n",
    "\n",
    "save_path = \"F:\\HQData\\BI-基本信息\\\\\"\n",
    "\n",
    "a_stock = save_path + 'a_stocks.csv'\n",
    "ngw_a_stock = save_path + 'ngw_a_stocks.xlsx'\n",
    "ngw_stocks = save_path +'ngw_all_a_stocks.xls'\n",
    "ngw_stock_csv = save_path + 'SECURITIES_INNERCODE.csv'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>InnerCode</th>\n",
       "      <th>TradingCode</th>\n",
       "      <th>SecuAbbr</th>\n",
       "      <th>ChiSpelling</th>\n",
       "      <th>SecuCategory</th>\n",
       "      <th>SecuCategoryCodeII</th>\n",
       "      <th>ExchangeCode</th>\n",
       "      <th>ExchangeName</th>\n",
       "      <th>ListingStateCode</th>\n",
       "      <th>CreateOn</th>\n",
       "      <th>LastUpdateOn</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>000001</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>PAYH</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>1</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>29/7/2020 16:50:55.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>000002</td>\n",
       "      <td>万  科Ａ</td>\n",
       "      <td>WKA</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>1</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>29/7/2020 16:50:55.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>000003</td>\n",
       "      <td>PT金田Ａ</td>\n",
       "      <td>PTJTA</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>0</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>22/5/2021 00:06:52.833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>000004</td>\n",
       "      <td>国华网安</td>\n",
       "      <td>GHWA</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>1</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>29/7/2020 16:50:55.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>000005</td>\n",
       "      <td>ST星源</td>\n",
       "      <td>STXY</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>1</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>29/7/2020 16:50:55.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   InnerCode TradingCode SecuAbbr ChiSpelling SecuCategory  \\\n",
       "0          1      000001     平安银行        PAYH           A股   \n",
       "1          2      000002    万  科Ａ         WKA           A股   \n",
       "2          3      000003    PT金田Ａ       PTJTA           A股   \n",
       "3          4      000004     国华网安        GHWA           A股   \n",
       "4          5      000005     ST星源        STXY           A股   \n",
       "\n",
       "   SecuCategoryCodeII  ExchangeCode ExchangeName  ListingStateCode  \\\n",
       "0                1001           105      深圳证券交易所                 1   \n",
       "1                1001           105      深圳证券交易所                 1   \n",
       "2                1001           105      深圳证券交易所                 0   \n",
       "3                1001           105      深圳证券交易所                 1   \n",
       "4                1001           105      深圳证券交易所                 1   \n",
       "\n",
       "                 CreateOn            LastUpdateOn  \n",
       "0  29/7/2020 14:05:27.613   29/7/2020 16:50:55.55  \n",
       "1  29/7/2020 14:05:27.613   29/7/2020 16:50:55.55  \n",
       "2  29/7/2020 14:05:27.613  22/5/2021 00:06:52.833  \n",
       "3  29/7/2020 14:05:27.613   29/7/2020 16:50:55.55  \n",
       "4  29/7/2020 14:05:27.613   29/7/2020 16:50:55.55  "
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all =  pd.read_csv(ngw_stock_csv)\n",
    "df_all.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>38</th>\n",
       "      <th>39</th>\n",
       "      <th>40</th>\n",
       "      <th>41</th>\n",
       "      <th>42</th>\n",
       "      <th>43</th>\n",
       "      <th>44</th>\n",
       "      <th>45</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>600248</td>\n",
       "      <td>陕西建工</td>\n",
       "      <td>SXJG</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>2000-06-22 00:00:00</td>\n",
       "      <td>7.6799</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6</td>\n",
       "      <td>600836</td>\n",
       "      <td>上海易连</td>\n",
       "      <td>SHYL</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>1994-02-24 00:00:00</td>\n",
       "      <td>4.0000</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>600556</td>\n",
       "      <td>天下秀</td>\n",
       "      <td>TXX</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>2001-08-07 00:00:00</td>\n",
       "      <td>9.5998</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   0       1     2     3     4   5    6        7                    8   \\\n",
       "0   1  600248  陕西建工  SXJG  1001  A股  101  上海证券交易所  2000-06-22 00:00:00   \n",
       "1   6  600836  上海易连  SHYL  1001  A股  101  上海证券交易所  1994-02-24 00:00:00   \n",
       "2   7  600556   天下秀   TXX  1001  A股  101  上海证券交易所  2001-08-07 00:00:00   \n",
       "\n",
       "       9   ...   36   37   38  39 40 41  42  43   44 45  \n",
       "0  7.6799  ...  NaN  NaN  NaN NaN  0  1 NaN NaN  0.0  0  \n",
       "1  4.0000  ...  NaN  NaN  NaN NaN  0  0 NaN NaN  0.0  0  \n",
       "2  9.5998  ...  NaN  NaN  NaN NaN  1  1 NaN NaN  0.0  0  \n",
       "\n",
       "[3 rows x 46 columns]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all = pd.read_excel(ngw_stocks, header=None)\n",
    "df_all.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>38</th>\n",
       "      <th>39</th>\n",
       "      <th>40</th>\n",
       "      <th>41</th>\n",
       "      <th>42</th>\n",
       "      <th>43</th>\n",
       "      <th>44</th>\n",
       "      <th>45</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4</td>\n",
       "      <td>605589</td>\n",
       "      <td>圣泉集团</td>\n",
       "      <td>SQJT</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>NaT</td>\n",
       "      <td>24.01</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6</td>\n",
       "      <td>605588</td>\n",
       "      <td>冠石科技</td>\n",
       "      <td>GSKJ</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>NaT</td>\n",
       "      <td>27.42</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>17</td>\n",
       "      <td>601825</td>\n",
       "      <td>沪农商行</td>\n",
       "      <td>HNSH</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>NaT</td>\n",
       "      <td>8.90</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   0       1     2     3     4   5    6        7   8      9   ...  36  37  38  \\\n",
       "0   4  605589  圣泉集团  SQJT  1001  A股  101  上海证券交易所 NaT  24.01  ... NaN NaN NaN   \n",
       "1   6  605588  冠石科技  GSKJ  1001  A股  101  上海证券交易所 NaT  27.42  ... NaN NaN NaN   \n",
       "2  17  601825  沪农商行  HNSH  1001  A股  101  上海证券交易所 NaT   8.90  ... NaN NaN NaN   \n",
       "\n",
       "   39 40 41  42  43  44 45  \n",
       "0 NaN  0  0 NaN NaN NaN  0  \n",
       "1 NaN  0  0 NaN NaN NaN  0  \n",
       "2 NaN  0  0 NaN NaN NaN  0  \n",
       "\n",
       "[3 rows x 46 columns]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# sql = ' select * from STK_BASICINFO where '\n",
    "# df_a = pd.read_excel(ngw_stocks, encoding='gbk', header=None)\n",
    "df_a = pd.read_excel(ngw_a_stock, encoding='gbk', header=None)\n",
    "\n",
    "df_a.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data_from_ngw(url):\n",
    "    import requests\n",
    "    import json\n",
    "\n",
    "    headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}  \n",
    "\n",
    "    html = requests.get(url, headers=headers)\n",
    "    \n",
    "    data_list = json.loads(html.text)\n",
    "    timedata = data_list[\"timedata\"]\n",
    "    \n",
    "    df_timedata=pd.DataFrame(timedata)\n",
    "    \n",
    "    if len(df_timedata) == 0:\n",
    "        # print('没有获取到timedata', url)\n",
    "        return df_timedata\n",
    "\n",
    "    df_timedata.times=df_timedata.times.apply(lambda x:  datetime.datetime.strptime(x[:-6], \"%Y%m%d\"))\n",
    "    df_timedata.set_index(\"times\", drop=True,inplace=True)\n",
    "    #dfnowv=dfnowv.map(lambda x:float(x)/100) \n",
    "    df_timedata.openp = df_timedata.openp.astype(float)/100\n",
    "    df_timedata.highp = df_timedata.highp.astype(float)/100\n",
    "    df_timedata.lowp = df_timedata.lowp.astype(float)/100\n",
    "    df_timedata.nowv = df_timedata.nowv.astype(float)/100\n",
    "    df_timedata.preclose = df_timedata.preclose.astype(float)/100\n",
    "\n",
    "    df_timedata.curvol = df_timedata.curvol.astype(float)\n",
    "    df_timedata.curvalue = df_timedata.curvalue.astype(float)\n",
    "    return df_timedata\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_by_innercode(code):\n",
    "    url = \"https://shq.niuguwang.com/aquote/quote/kline.ashx?code={}&start=20220110094500&count=10000&type=5&std=1\".format(code)\n",
    "   \n",
    "    df = get_data_from_ngw(url)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# 创建新线程\n",
    "thread1 = myThread(, \"Thread-1\", 1)\n",
    "thread2 = myThread(2, \"Thread-2\", 2)\n",
    " \n",
    "# 开启线程\n",
    "thread1.start()\n",
    "thread2.start()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "'timedata'\n",
      "end\n"
     ]
    }
   ],
   "source": [
    "#for idx,  row in df_all.iterrows():\n",
    "for idx,  row in df_sh.iterrows():\n",
    "# for idx,  row in df_sz.iterrows():\n",
    "    try:\n",
    "        code = row['InnerCode']\n",
    "        TradingCode = row['TradingCode']\n",
    "        SecuAbbr = row['SecuAbbr']\n",
    "        \n",
    "        url = \"https://shq.niuguwang.com/aquote/quote/kline.ashx?code={}&start=20220110094500&count=10000&type=5&std=1\".format(code)\n",
    "        # 从start开始往前数\n",
    "        # url = 'https://shq.niuguwang.com/aquote/quote/kline.ashx?code={}&start=20220520094500&count=10000&type=5&std=1'.format(row[1])\n",
    "        # print(row[0])\n",
    "        # print(url)\n",
    "        content = 'innercode:{}, {}-{} url:{}\\n'.format(code, TradingCode, SecuAbbr, url)\n",
    "        # content = 'innercode:{}, {}-{} url:{}\\n'.format(row[1], row[2], row[3], url)\n",
    "        #print(content)\n",
    "        df = get_data_from_ngw(url)\n",
    "        if df is None or len(df) == 0:\n",
    "            continue\n",
    "            \n",
    "        df.to_csv('{}{}.csv'.format(a_path, str(TradingCode).rjust(5, '0')))\n",
    "        apath = a_path + '/a_zhuban_stock.txt'\n",
    "        file_handle=open(apath,mode='a+')\n",
    "        file_handle.write(content)\n",
    "        file_handle.close()\n",
    "        \n",
    "    except Exception as e:\n",
    "        print(e)\n",
    "\n",
    "print('end')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100334"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df_all)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all[df_all[11] == 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>38</th>\n",
       "      <th>39</th>\n",
       "      <th>40</th>\n",
       "      <th>41</th>\n",
       "      <th>42</th>\n",
       "      <th>43</th>\n",
       "      <th>44</th>\n",
       "      <th>45</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3059</th>\n",
       "      <td>5983</td>\n",
       "      <td>002459</td>\n",
       "      <td>晶澳科技</td>\n",
       "      <td>JAKJ</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>105</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>2010-08-10 00:00:00</td>\n",
       "      <td>22.46</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        0       1     2     3     4   5    6        7                    8   \\\n",
       "3059  5983  002459  晶澳科技  JAKJ  1001  A股  105  深圳证券交易所  2010-08-10 00:00:00   \n",
       "\n",
       "         9   ...   36   37   38  39 40 41  42  43   44 45  \n",
       "3059  22.46  ...  NaN  NaN  NaN NaN  0  0 NaN NaN  1.0  1  \n",
       "\n",
       "[1 rows x 46 columns]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "df_all[df_all[2] == '晶澳科技']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>TradingCode</th>\n",
       "      <th>SecuAbbr</th>\n",
       "      <th>ChiSpelling</th>\n",
       "      <th>SecuCategoryCodeII</th>\n",
       "      <th>SecuCategory</th>\n",
       "      <th>ExchangeCode</th>\n",
       "      <th>ExchangeName</th>\n",
       "      <th>ListingDate</th>\n",
       "      <th>DistPrice</th>\n",
       "      <th>...</th>\n",
       "      <th>Remark</th>\n",
       "      <th>StockType</th>\n",
       "      <th>TransactionType</th>\n",
       "      <th>ZuoShiShangNum</th>\n",
       "      <th>SHHKStockConnect</th>\n",
       "      <th>SHHKStockConnectFull</th>\n",
       "      <th>Lots</th>\n",
       "      <th>ABFund</th>\n",
       "      <th>SZHKStockConnect</th>\n",
       "      <th>SZHKStockConnectFull</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>600248</td>\n",
       "      <td>陕西建工</td>\n",
       "      <td>SXJG</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>22/6/2000 00:00:00</td>\n",
       "      <td>7.6799</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6</td>\n",
       "      <td>600836</td>\n",
       "      <td>上海易连</td>\n",
       "      <td>SHYL</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>24/2/1994 00:00:00</td>\n",
       "      <td>4.0000</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>600556</td>\n",
       "      <td>天下秀</td>\n",
       "      <td>TXX</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>7/8/2001 00:00:00</td>\n",
       "      <td>9.5998</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>8</td>\n",
       "      <td>600707</td>\n",
       "      <td>彩虹股份</td>\n",
       "      <td>CHGF</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>20/5/1996 00:00:00</td>\n",
       "      <td>1.5000</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10</td>\n",
       "      <td>600012</td>\n",
       "      <td>皖通高速</td>\n",
       "      <td>WTGS</td>\n",
       "      <td>1001</td>\n",
       "      <td>A股</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>7/1/2003 00:00:00</td>\n",
       "      <td>2.2000</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   ID TradingCode SecuAbbr ChiSpelling  SecuCategoryCodeII SecuCategory  \\\n",
       "0   1      600248     陕西建工        SXJG                1001           A股   \n",
       "1   6      600836     上海易连        SHYL                1001           A股   \n",
       "2   7      600556      天下秀         TXX                1001           A股   \n",
       "3   8      600707     彩虹股份        CHGF                1001           A股   \n",
       "4  10      600012     皖通高速        WTGS                1001           A股   \n",
       "\n",
       "   ExchangeCode ExchangeName         ListingDate  DistPrice  ... Remark  \\\n",
       "0           101      上海证券交易所  22/6/2000 00:00:00     7.6799  ...    NaN   \n",
       "1           101      上海证券交易所  24/2/1994 00:00:00     4.0000  ...    NaN   \n",
       "2           101      上海证券交易所   7/8/2001 00:00:00     9.5998  ...    NaN   \n",
       "3           101      上海证券交易所  20/5/1996 00:00:00     1.5000  ...    NaN   \n",
       "4           101      上海证券交易所   7/1/2003 00:00:00     2.2000  ...    NaN   \n",
       "\n",
       "   StockType TransactionType  ZuoShiShangNum SHHKStockConnect  \\\n",
       "0        NaN             NaN             NaN                0   \n",
       "1        NaN             NaN             NaN                0   \n",
       "2        NaN             NaN             NaN                1   \n",
       "3        NaN             NaN             NaN                0   \n",
       "4        NaN             NaN             NaN                1   \n",
       "\n",
       "  SHHKStockConnectFull Lots ABFund SZHKStockConnect SZHKStockConnectFull  \n",
       "0                    1  NaN    NaN              0.0                    0  \n",
       "1                    0  NaN    NaN              0.0                    0  \n",
       "2                    1  NaN    NaN              0.0                    0  \n",
       "3                    0  NaN    NaN              0.0                    0  \n",
       "4                    1  NaN    NaN              0.0                    0  \n",
       "\n",
       "[5 rows x 46 columns]"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17725"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all = df_all[df_all['SecuCategory'] == 'A股']\n",
    "len(df_all)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{101, 105, 111}"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set(df_all.ExchangeCode.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BATS交易所',\n",
       " nan,\n",
       " '上海证券交易所',\n",
       " '场外基金',\n",
       " '新三板交易市场',\n",
       " '深圳证券交易所',\n",
       " '深证证券交易所',\n",
       " '美国纳斯达克证券交易所',\n",
       " '美国纽约证券交易所',\n",
       " '美国证券交易所',\n",
       " '香港联合交易所'}"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set(df_all.ExchangeName)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_sh = df_all[df_all['ExchangeName'] == '上海证券交易所']\n",
    "df_sz = df_all[df_all['ExchangeName'] == '深圳证券交易所']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all[df_all['ExchangeName'] == '深证证券交易所']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>InnerCode</th>\n",
       "      <th>TradingCode</th>\n",
       "      <th>SecuAbbr</th>\n",
       "      <th>ChiSpelling</th>\n",
       "      <th>SecuCategory</th>\n",
       "      <th>SecuCategoryCodeII</th>\n",
       "      <th>ExchangeCode</th>\n",
       "      <th>ExchangeName</th>\n",
       "      <th>ListingStateCode</th>\n",
       "      <th>CreateOn</th>\n",
       "      <th>LastUpdateOn</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2405</th>\n",
       "      <td>3216</td>\n",
       "      <td>600600</td>\n",
       "      <td>青岛啤酒</td>\n",
       "      <td>QDPJ</td>\n",
       "      <td>A股</td>\n",
       "      <td>1001</td>\n",
       "      <td>101</td>\n",
       "      <td>上海证券交易所</td>\n",
       "      <td>1</td>\n",
       "      <td>29/7/2020 14:05:27.613</td>\n",
       "      <td>29/7/2020 16:50:55.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      InnerCode TradingCode SecuAbbr ChiSpelling SecuCategory  \\\n",
       "2405       3216      600600     青岛啤酒        QDPJ           A股   \n",
       "\n",
       "      SecuCategoryCodeII  ExchangeCode ExchangeName  ListingStateCode  \\\n",
       "2405                1001           101      上海证券交易所                 1   \n",
       "\n",
       "                    CreateOn           LastUpdateOn  \n",
       "2405  29/7/2020 14:05:27.613  29/7/2020 16:50:55.55  "
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all[df_all['SecuAbbr'] == '青岛啤酒']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfjakj.to_csv('{}{}.csv'.format(a_path, str('002459').rjust(5, '0')))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
